<template>
	<view class="page">
		<!-- <page-head :title="title"></page-head> -->
		<view class="uni-common-mt">
			<form @submit="saveData">
				<view class="uni-list">
					<view class="uni-list-cell">
						<view class="uni-list-cell-left">
							<view class="uni-label">服务器Url：</view>
						</view>
					</view>
					<view class="uni-list-cell">
						<view class="uni-list-cell-left">
							<input class="uni-input" placeholder="" v-model="ls_baseUrl" name="baseUrl"></input>
						</view>
					</view>
				</view>
				<view class="uni-padding-wrap" style="margin-top: 50upx;">
					<view class="uni-flex uni-row">
						<button formType="submit" class="btn-save">保存</button>
						<button class="btn-del" @tap="cancel">取消</button>
					</view>
				</view>
			</form>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {

		data() {
			return {
				ls_baseUrl: 'https://d.m-cloud.cc',
			};
		},
		onShow() {
			let url = uni.getStorageSync('ls_baseUrl')
			if (url){
				this.ls_baseUrl = url.substr(0,url.length-4 )
			}
		},
		methods: {
			saveData() {
				this.$http.config.baseUrl = this.ls_baseUrl + '/api'
				uni.setStorageSync('ls_baseUrl',this.ls_baseUrl+ '/api')
				this.$tip.success('保存成功');
				uni.reLaunch({
							url: '/pages/login/login'
				 });
			},
			cancel() {
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style>
	.uni-list-cell:after {
		left: 20upx;
	}

	.uni-list-cell {
		height: 100upx;
	}

	.uni-input {
		width: 450upx;
		text-align: left;
		height: 100upx;
		font-size: 36upx;
		line-height: 100upx;
	}

	.uni-list {
		margin-bottom: 30upx;
	}

	.title {
		padding: 10px 0;
		width: 120px
	}

	.btn-save {
		background: #00aaff;
		color: #FFFFFF;
		width: 150px;
		/* display: inline-block; */
		/* max-width: none; */
	}

	.btn-del {
		background: #fa6b4b;
		color: #FFFFFF;
		width: 150px;
		/* display: inline-block; */
	}

	/* .btn-bottom{
		display: flex;
		padding:10upx 0;
		flex-direction: row;
	} */
	.uni-list-cell {
		padding-right: 20upx;
	}
</style>
